var dbName = "ClientPlatform";
var newCriteriaName = "ESG Risk Rating Percentile - Subindustry";
var level3 = db.getSiblingDB(dbName).CriteriaLevel3.findOne({Name: /ESG Risk Rating Percentile/})
var templateCriteria = db.getSiblingDB(dbName).TemplateCriteria.findOne({Name: newCriteriaName})

if (!templateCriteria){
    db.getSiblingDB(dbName).getCollection('TemplateCriteria').insertOne({
        "_id" : NUUID("1f0563e9-b47e-4225-9b36-c256fa036e14"),
        "Name" : newCriteriaName,
        "CriteriaEntity" : null,
        "CriteriaEntityField" : "ESG Risk Rating Percentile-Subindustry",
        "CriteriaType" : 6,
        "CriteriaLevel2Id" : level3.CriteriaLevel2Id,
        "CriteriaLevel3Id" : level3._id,
        "IsScreenable" : false,
        "ResearchProducts" : [ 
            "RiskRating"
        ],
        "GetsValueFromParent" : true,
        "HasFullRangeChart" : true
    })
}
else
{
    print("Criteria has already been inserted");
}


